﻿using System;
using System.Windows;

namespace VXCompany.SilverlightLogging.MVVM.Models.SyncBehaviors
{
	public class AppEndSync : SyncBehavior
	{
		/// <summary>
		/// Starts behavior
		/// </summary>
		protected override void StartImpl()
		{
			Application.Current.Exit += Current_Exit;
		}

		/// <summary>
		/// Stops behavior
		/// </summary>
		protected override void StopImpl()
		{
			Application.Current.Exit -= Current_Exit;
		}

		/// <summary>
		/// EventHandler for application exit.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void Current_Exit(object sender, EventArgs e)
		{
			BeginSynchronize();
		}
	}
}
